/*
 * @(#)NoticeDAOImpl.java $version 2013-3-4
 * 
 * Copyright 2013 NADO Group. All rights Reserved.
 * NADO PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nado.iims2.community.dao.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.nado.extensions.sql.SimpleSqlMapDaoSupport;
import com.nado.extensions.util.DataMap;
import com.nado.iims2.community.dao.NoticeDAO;
import com.nado.iims2.community.model.NoticeModel;

/**
 * The Class NoticeDAOImpl.
 * 
 * @author nado
 */
@Repository("NoticeDAO")
public class NoticeDAOImpl extends SimpleSqlMapDaoSupport implements NoticeDAO {
	/** The Contents PREFIX. */
	private final static String PREFIX = "com.nado.iims2.community.notice.";
	
	@Override
	public List<DataMap> selectNoticeList(String startDate, String endDate, String typeCd, int offset, int count)
			throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("startDate", startDate);
		params.put("endDate", endDate);
		params.put("typeCd", typeCd);
		params.put("offset", offset);
		params.put("count", count);
		
		return getSqlMapClient().queryForList(PREFIX + "selectNoticeList", params);
	}

	@Override
	public int selectNoticeListCount(String startDate, String endDate, String typeCd) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("startDate", startDate);
		params.put("endDate", endDate);
		params.put("typeCd", typeCd);
		
		return (Integer) getSqlMapClient().queryForObject(PREFIX + "selectNoticeListCount", params);
	}

	@Override
	public int insertNotice(NoticeModel model) throws SQLException {
		return getSqlMapClient().update(PREFIX + "insertNotice", model);
	}

	@Override
	public int updateNotice(NoticeModel model) throws SQLException {
		return getSqlMapClient().update(PREFIX + "updateNotice", model);
	}

	@Override
	public int deleteNotice(int noticeNo) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("noticeNo", noticeNo);
		
		return getSqlMapClient().delete(PREFIX + "deleteNotice", params);
	}

	@Override
	public NoticeModel selectNoticeDetail(int noticeNo) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("noticeNo", noticeNo);
		
		return (NoticeModel) getSqlMapClient().queryForObject(PREFIX + "selectNoticeDetail", params);
	}

}
